/**
 * 
 */
package common;

import java.util.ArrayList;
import java.util.Stack;

import model.Pzombiedactyl;
import model.State;
import model.TrailTile;
import model.Zombosaur;

/**
 * @author Bill
 *
 *This class is used to store useful information. For example,
 *the names of image files for certain objects, as well as arrays
 *representing trails for the map.
 */
public class DataManager {
	
	/*************************************************************
	 * Image Files
	 *************************************************************/
	
	//Backgrounds and Tiles and other random images
	public static final String SPACESHIP_IMAGE = "Spaceship.png";
	public static final String HEALTH_ICON = "Heart.png";
	public static final String LEVEL1_BACKGROUND_TILE = "CanopySquare.png";
	public static final String LEVEL1_TRAIL_TILE = "BrownSquare.png";
	public static final String LEVEL2_BACKGROUND_TILE = "IceBackgroundTile.png";
	public static final String LEVEL2_TRAIL_TILE = "IceTrailTile.png";
	public static final String LEVEL3_BACKGROUND_TILE = "LavaBackgroundTile.png";
	public static final String LEVEL3_TRAIL_TILE = "LavaTrailTile.png";
	public static final String TITLE_SCREEN = "TitleScreen.png";
	public static final String HOW_TO_PLAY_SCREEN = "HowToPlayScreen.png";
	public static final String INVENTORY_BACKGROUND = "InventoryBackground.png";
	public static final String INVENTORY_ICON_BACKGROUND = "WhiteIconBackground.png";
	public static final String INVENTORY_ICON_SELECTED = "IconSelected.png";
	public static final String UNAVAILABLE_ITEM_ICON_COVER = "GreyIconCover.png";
	public static final String ICON_COVER = "IconCover.png";
	public static final String TILE_COVER = "GreyCircle.png";
	public static final String EXPLOSION_1_BY_1 = "SmallExplosion.png";
	public static final String EXPLOSION_3_BY_3 = "ThreeByThreeExplosion.png";
	public static final String EXPLOSION_5_BY_5 = "FiveByFiveExplosion.png";
	public static final String EXPLOSION_ASTEROID = "AsteroidExplosion.png";
	public static final String SUICIDE_BUTTON = "SuicideButton.png";
	public static final String PAUSE_BUTTON = "PauseButton.png";
	
	//Automatic Weapons
	public static final String SMALL_TURRET = "SmallTurret.png";
	public static final String LARGE_TURRET = "LargeTurret.png";
	public static final String RAPID_FIRE_TURRET = "RapidFireTurret.png";
	public static final String SMALL_LASER = "SmallLaser.png";
	public static final String SLOWING_CANON = "SlowingCanon.png";
	
	//Manual Weapons
	public static final String SMALL_CANON = "smallCanonIcon.png";
	public static final String LARGE_CANON = "LargeCanonIcon.png";
	public static final String SMALL_HOMING_MISSILE = "SmallHomingMissileIcon.png";
	public static final String LARGE_HOMING_MISSILE = "LargeHomingMissile.png";
	public static final String ASTEROID = "AsteroidIcon.png";
	
	//Defensive Items
	public static final String WOOD_WALL = "WoodWall.png";
	public static final String BRICK_WALL = "BrickWall.png";
	public static final String FORCE_FIELD = "ForceField.png";
	public static final String MINE = "Mine.png";
	public static final String SPIKE_TRAP = "SpikeTrap.png";
	
	//Upgrades
	public static final String HEALTH_UPGRADE = "HealthUpgrade.png";
	public static final String REPAIR_UPGRADE = "RepairUpgrade.png";
	public static final String DAMAGE_UPGRADE = "DamageUpgradeIcon.png";
	public static final String RANGE_UPGRADE = "";
	public static final String RATE_UPGRADE = "";
	
	//Zombosaurs
	public static final String PZOMBIEDACTYL = "Pzombiedactyl.png";
	public static final String PZOMBIEDACTYL_FLIPPED = "Pzombiedactyl.png";
	public static final String BRONTOZOMBIE = "Brontozombie2.png";
	public static final String BRONTOZOMBIE_FLIPPED = "Brontozombie2Flipped.png";
	public static final String TRIZOMBIETOPS = "Trizombietops.png";
	public static final String TRIZOMBIETOPS_FLIPPED = "TrizombietopsFlipped.png";
	public static final String ZOMBLOCERAPTOR = "Zombloceraptor.png";
	public static final String ZOMBLOCERAPTOR_FLIPPED = "ZombloceraptorFlipped.png";
	public static final String TYRANNOZOMBIE_REX = "TyrannozombieRex.png";
	public static final String TYRANNOZOMBIE_REX_FLIPPED = "TyrannozombieRexFlipped.png";
	
	//Automatic Ammo
	public static final String SMALL_TURRET_AMMO = "SmallTurretAmmo.png";
	public static final String LARGE_TURRET_AMMO = "LargeTurretAmmo.png";
	public static final String RAPID_FIRE_TURRET_AMMO = "RapidFireTurretAmmo.png";
	public static final String SMALL_LASER_AMMO = "SmallLaserAmmo.png";
	public static final String SLOWING_CANON_AMMO = "SlowingTurretAmmo.png";
	
	//Manual Ammo
	public static final String SMALL_CANON_AMMO = "SmallCanonAmmo.png";
	public static final String LARGE_CANON_AMMO = "LargeCanonAmmo.png";
	public static final String SMALL_HOMING_MISSILE_AMMO = "SmallHomingMissileIcon.png";
	public static final String LARGE_HOMING_MISSILE_AMMO = "LargeHomingMissile.png";
	public static final String ASTEROID_AMMO = "AsteroidAmmo.png";
	
	/*************************************************************
	 * Names of the main "scenes" corresponding to states
	 *************************************************************/
	public static final String MAIN_MENU_PANEL_NAME = "MAIN_MENU";
	public static final String HOW_TO_PLAY_PANEL_NAME = "HOW_TO_PLAY_PANEL";
	public static final String GAME_PANEL_NAME = "GAME";
	public static final String PAUSE_PANEL_NAME = "PAUSE";
	
	/*************************************************************
	 * Methods
	 *************************************************************/
	/**
	 * This returns a string which is the name of the panel which
	 * corresponds to a given state
	 * 
	 * @param state 
	 * @return String : The name of the Panel to be displayed
	 */
	public static String getPanelNameFromState(State state){
		if(state.getStateName() == "MAIN_MENU") return MAIN_MENU_PANEL_NAME;
		else if(state.getStateName() == "HOW_TO_PLAY_STATE") return HOW_TO_PLAY_PANEL_NAME;
		else if(state.getStateName() == "ATTACK_STAGE_STATE" || state.getStateName() == "SETUP_STAGE_STATE") return GAME_PANEL_NAME;
		else if(state.getStateName() == "PAUSE_STATE") return PAUSE_PANEL_NAME;
		else return "NULL";
	}
	
	/**
	 * Gets a list of the file names for all the manual weapon types
	 * 
	 * @return ArrayList<String> : File names of manual weapon images
	 */
	public static ArrayList<String> getManualWeaponIcons(){
		ArrayList<String> manualWeapons = new ArrayList<String>(5);
		manualWeapons.add(SMALL_CANON);
		manualWeapons.add(LARGE_CANON);
		manualWeapons.add(SMALL_HOMING_MISSILE);
		manualWeapons.add(LARGE_HOMING_MISSILE);
		manualWeapons.add(ASTEROID);
		return manualWeapons;
	}
	
	/**
	 * Gets a list of the file names for all the automatic weapon types
	 * 
	 * @return ArrayList<String> : File names of automatic weapon images
	 */
	public static ArrayList<String> getAutomaticWeaponIcons(){
		ArrayList<String> autoWeapons = new ArrayList<String>(2);
		autoWeapons.add(SMALL_TURRET);
		autoWeapons.add(LARGE_TURRET);
		autoWeapons.add(SLOWING_CANON);
		autoWeapons.add(SMALL_LASER);
		autoWeapons.add(RAPID_FIRE_TURRET);
		
		return autoWeapons;
	}
	
	/**
	 * Gets a list of the file names for all the defensive item types
	 * 
	 * @return ArrayList<String> : File names of defensive items images
	 */
	public static ArrayList<String> getDefensiveItemIcons(){
		ArrayList<String> dItems = new ArrayList<String>(3);
		dItems.add(WOOD_WALL);
		dItems.add(BRICK_WALL);
		dItems.add(FORCE_FIELD);
		dItems.add(MINE);
		dItems.add(SPIKE_TRAP);
		return dItems;
	}
	
	/**
	 * Gets a list of the file names for all the upgrade types
	 * 
	 * @return ArrayList<String> : File names of defensive items images
	 */
	public static ArrayList<String> getUpgradeIcons(){
		ArrayList<String> dItems = new ArrayList<String>(1);
		dItems.add(HEALTH_UPGRADE);
		dItems.add(REPAIR_UPGRADE);
		dItems.add(DAMAGE_UPGRADE);
		return dItems;
	}
	
	
	/**
	 * This generates the appropriate trail for the specified level.
	 * NOTE: There is a specific order with which the trail tiles must be
	 * added to the ArrayList. They must be in the order that the zombos
	 * should traverse them.
	 * 
	 * @param level - selects the trail of the specified level
	 * @return trail - ArrayList of Tiles representing the trail 
	 */
	public static ArrayList<TrailTile> getTrail(int level){
		
		ArrayList<TrailTile> trail = new ArrayList();
		
		switch(level){
		case 1: 
			trail.add(new TrailTile(-1,9));
			trail.add(new TrailTile(0,9));
			trail.add(new TrailTile(1,9));
			trail.add(new TrailTile(1,8));
			trail.add(new TrailTile(1,7));
			trail.add(new TrailTile(1,6));
			trail.add(new TrailTile(1,5));
			trail.add(new TrailTile(1,4));
			trail.add(new TrailTile(1,3));
			trail.add(new TrailTile(2,3));
			trail.add(new TrailTile(3,3));
			trail.add(new TrailTile(3,4));
			trail.add(new TrailTile(3,5));
			trail.add(new TrailTile(3,6));
			trail.add(new TrailTile(4,6));
			trail.add(new TrailTile(4,7));
			trail.add(new TrailTile(4,8));
			trail.add(new TrailTile(5,8));
			trail.add(new TrailTile(6,8));
			trail.add(new TrailTile(7,8));
			trail.add(new TrailTile(7,7));
			trail.add(new TrailTile(7,6));
			trail.add(new TrailTile(7,5));
			trail.add(new TrailTile(7,4));
			trail.add(new TrailTile(6,4));
			trail.add(new TrailTile(5,4));
			trail.add(new TrailTile(5,3));
			trail.add(new TrailTile(5,2));
			trail.add(new TrailTile(5,1));
			trail.add(new TrailTile(6,1));
			trail.add(new TrailTile(7,1));
			trail.add(new TrailTile(8,1));
			trail.add(new TrailTile(9,1));
			trail.add(new TrailTile(9,2));
			trail.add(new TrailTile(9,3));
			trail.add(new TrailTile(9,4));
			trail.add(new TrailTile(9,5));
			trail.add(new TrailTile(9,6));
			trail.add(new TrailTile(10,6));
			trail.add(new TrailTile(11,6));
			trail.add(new TrailTile(11,5));
			trail.add(new TrailTile(12,5));
			break;
		case 2: 
			trail.add(new TrailTile(-1,2));
			trail.add(new TrailTile(0,2));
			trail.add(new TrailTile(1,2));
			trail.add(new TrailTile(2,2));
			trail.add(new TrailTile(2,3));
			trail.add(new TrailTile(2,4));
			trail.add(new TrailTile(2,5));
			trail.add(new TrailTile(3,5));
			trail.add(new TrailTile(4,5));
			trail.add(new TrailTile(4,4));
			trail.add(new TrailTile(5,4));
			trail.add(new TrailTile(6,4));
			trail.add(new TrailTile(7,4));
			trail.add(new TrailTile(7,3));
			trail.add(new TrailTile(7,2));
			trail.add(new TrailTile(8,2));
			trail.add(new TrailTile(9,2));
			trail.add(new TrailTile(9,3));
			trail.add(new TrailTile(9,4));
			trail.add(new TrailTile(9,5));
			trail.add(new TrailTile(9,6));
			trail.add(new TrailTile(8,6));
			trail.add(new TrailTile(7,6));
			trail.add(new TrailTile(7,7));
			trail.add(new TrailTile(7,8));
			trail.add(new TrailTile(8,8));
			trail.add(new TrailTile(9,8));
			trail.add(new TrailTile(10,8));
			trail.add(new TrailTile(11,8));
			trail.add(new TrailTile(11,7));
			trail.add(new TrailTile(11,6));
			trail.add(new TrailTile(11,5));
			trail.add(new TrailTile(12,5));
			break;
		case 3: 
			trail.add(new TrailTile(-1,4));
			trail.add(new TrailTile(0,4));
			trail.add(new TrailTile(1,4));
			trail.add(new TrailTile(2,4));
			trail.add(new TrailTile(3,4));
			trail.add(new TrailTile(4,4));
			trail.add(new TrailTile(4,3));
			trail.add(new TrailTile(4,2));
			trail.add(new TrailTile(5,2));
			trail.add(new TrailTile(6,2));
			trail.add(new TrailTile(6,3));
			trail.add(new TrailTile(6,4));
			trail.add(new TrailTile(6,5));
			trail.add(new TrailTile(6,6));
			trail.add(new TrailTile(7,6));
			trail.add(new TrailTile(8,6));
			trail.add(new TrailTile(8,5));
			trail.add(new TrailTile(9,5));
			trail.add(new TrailTile(10,5));
			trail.add(new TrailTile(11,5));
			trail.add(new TrailTile(12,5));
			break;
		default: return getTrail(1); 
		}
		return trail;
	}
	
	/**
	 * Returns a string with the filename of a trail tile
	 * @param level
	 */
	public static String getTrailTileName(int level){
		switch(level){
		case 1: return LEVEL1_TRAIL_TILE;
		case 2: return LEVEL2_TRAIL_TILE;
		case 3: return LEVEL3_TRAIL_TILE;
		default: return LEVEL1_TRAIL_TILE;
		}
	}
	
	/**
	 * Returns a string with the filename of a background tile
	 * @param level
	 */
	public static String getBackgroundTileName(int level){
		switch(level){
		case 1: return LEVEL1_BACKGROUND_TILE;
		case 2: return LEVEL2_BACKGROUND_TILE;
		case 3: return LEVEL3_BACKGROUND_TILE;
		default: return LEVEL1_BACKGROUND_TILE;
		}
	}

}
